package com.cxso.example.request.report;

import com.cxso.example.enums.report.LocationModeEnum;
import com.cxso.example.enums.report.StartAndEndEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;
import java.util.List;


@Getter
@Setter
public class ReportTrackRequest implements Serializable {

    @NotBlank
    @Schema(description = "主体id")
    private String bodyId;


    @Schema(description = "运单号")
    @NotBlank(message = "运单号不能为空")
    private String shippingNoteNumber;

    @Valid
    @NotEmpty
    @Schema(description = "轨迹", example = "完整轨迹")
    private List<Track> trackList;


    @Getter
    @Setter
    public static class Track {

        @NotNull(message = "定位方式不能为空")
        @Schema(description = "定位方式")
        private LocationModeEnum locationMethod;

        @NotNull(message = "定位方式不能为空")
        @Schema(description = "定位时间")
        private Date locationTime;

        @Schema(description = "定位位置")
        private String locationAddress;

        @Pattern(regexp = "^[\\-]?(0(\\.\\d{1,6})?|([1-9](\\d)?)(\\.\\d{1,6})?|1[0-7]\\d(\\.\\d{1,6})?|180(\\.0{1,6})?)$", message = "经度格式错误")
        @NotBlank(message = "经度不能为空")
        @Schema(description = "经度")
        private String longitude;

        @Pattern(regexp = "^[\\-]?((0|([1-8]\\d?))(\\.\\d{1,6})?|90(\\.0{1,6})?)$", message = "纬度格式错误")
        @NotBlank(message = "纬度不能为空")
        @Schema(description = "纬度")
        private String latitude;

        @Schema(description = "提货/运抵")
        private StartAndEndEnum locationType;
    }

}
